package weekend4;

import java.io.File;
import java.io.FileFilter;

public class FileDemo {
    public static void main(String[] args) {
        /*File file=new File("./note.txt");
        System.out.println(file.canWrite());
        System.out.println(file.isHidden());
        System.out.println(file.length());
        System.out.println(file.getName());

         */

        File file1=new File(".");
        if(file1.isDirectory()){
            File[] arr=file1.listFiles();
            for(File file:arr){
                System.out.println(file.getName());
            }
        }else{
            System.out.println("不是目录或该目录不存在");
        }

        File file2=new File(".");
        if(file2.isDirectory()){
            File[] subs=file2.listFiles(new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                    String name=pathname.getName();
                    return name.contains("t");
                }
            });
            for(File sub:subs){
                System.out.println(sub.getName());
            }
        }

        File file3=new File(".");
        File[] a=file3.listFiles(pathname ->pathname.getName().endsWith("c"));
        for(File b:a){
            System.out.println(b.getName());
        }

    }
}
